home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / archivers / xfd / developer / sources / asm / imploderclone.a < prev    next >
Text File  |  1999-06-14  |  3KB  |  114 lines

  1. ***************************************************************
  2. **   XFD external decruncher for recognising the Imploder    **
  3. **    Hack as used on the PC Task executables.             **
  4. ***************************************************************
  5.  
  6.         SECTION    ImploderHack,CODE
  7.  
  8.         INCLUDE    AINCLUDE:IncDirs.i
  9.         INCLUDE    "libraries/xfdmaster.i"
  10.         INCLUDE    lvo.i
  11.  
  12. ; xfdForeman structure MUST be first thing in all external decrunchers
  13.  
  14. F_ImploderHack    moveq    #-1,d0            ;security
  15.         rts
  16.  
  17.         dc.l    XFDF_ID            ;id
  18.         dc.w    1            ;version
  19.         dc.w    0
  20.         dc.l    0,0            ;private
  21.         dc.l    S_ImploderHack        ;first slave
  22.  
  23. **************************************************
  24.  
  25. ; xfdSlave structure: this one doesn't support segment decrunching
  26.  
  27. S_ImploderHack    dc.l    0            ;no more slaves
  28.         dc.w    1            ;version
  29.         dc.w    33            ;master version
  30.         dc.l    N_ImploderHack        ;name
  31.         dc.w    XFDPFF_RELOC        ;flags
  32.         dc.w    0
  33.         dc.l    RB_ImploderHack        ;recog buffer
  34.         dc.l    DB_ImploderHack        ;decrunch buffer
  35.         dc.l    0            ;recog segment
  36.         dc.l    0            ;decrunch segment
  37.  
  38. N_ImploderHack    dc.b    'Imploder Clone',0
  39.         even
  40.  
  41. ;-------------------------------------------------
  42.  
  43. ; Recog buffer function: receives buffer + length in a0/d0
  44.  
  45. RB_ImploderHack    Moveq.l    #1,d0            ; True
  46.         Cmp.l    #$3f3,(a0)+        ; Is this an executable?
  47.         Bne.b    .No
  48.         TST.L    4(A0)
  49.         BNE.B    .No
  50.  
  51.         Move.l    4(a0),d1
  52.         Add.l    d1,d1
  53.         Add.l    d1,d1            ; x4
  54.         Add.l    d1,a0
  55.         Lea    4*4(a0),a0        ; Skip the first/last hunk numbers,
  56.                         ; and 
  57.  
  58.         Cmp.l    #$3e9,(a0)
  59.         bne.b    .No
  60.  
  61.         Cmp.l    #$48e7ffff,8(a0)    ; This is on all IMPLODER files
  62.         Bne.b    .No
  63.  
  64.         Cmp.l    #$7cff4486,12(a0)    ; Moveq.l #-1,d6
  65.         Bne.b    .No
  66.  
  67.         Cmp.l    #$49fa005a,16(a0)    ; Neg d6
  68.         Beq.b    .Yes
  69.  
  70.  
  71. .No        Moveq.l    #0,d0
  72. .Yes        rts
  73.  
  74. ;-------------------------------------------------
  75.  
  76. ;Decrunch buffer function: receives bufferinfo in a0
  77.  
  78. DB_ImploderHack    MOVEM.L    d2-d7/a2-a6,-(A7)
  79.         move.l    a0,a5
  80.  
  81.         Move.l    xfdbi_SourceBufLen(a5),d0
  82.         move.l    d0,xfdbi_TargetBufSaveLen(a5)
  83.         move.l    d0,xfdbi_TargetBufLen(a5)
  84.  
  85.         move.l    xfdbi_TargetBufMemType(a5),d1
  86.         move.l    4.w,a6
  87.         JSR    _LVOAllocMem(A6)
  88.         moveq    #XFDERR_NOMEMORY,d1
  89.         Move.w    d1,xfdbi_Error(a5)
  90.         move.l    d0,xfdbi_TargetBuffer(a5)
  91.         beq.b    .NoMem
  92.  
  93.         Clr.w    xfdbi_Error(a5)
  94.  
  95.         Move.l    d0,a1
  96.         Move.l    xfdbi_SourceBuffer(a5),a0
  97.         Move.l    xfdbi_SourceBufLen(a5),d0
  98.         JSR    _LVOCopyMem(A6)
  99.  
  100.         move.l    xfdbi_TargetBuffer(a5),a0
  101. .SeekStart    Cmp.l    #$3e9,(a0)+
  102.         Bne.b    .SeekStart
  103.  
  104.         Move.l    #$49fa005e,8(a0)
  105.         Move.l    #$3c3c0002,12(a0)
  106.  
  107.         Moveq.l    #1,d0        ; True = Decrunched ok
  108. .NoMem        MOVEM.L    (A7)+,d2-d7/a2-a6
  109.         Rts
  110.  
  111. **************************************************
  112.  
  113.         END
  114.